#include <stdio.h>
typedef struct {
    char name[9];
    int year;
    int month;
    int day;
} Friend;

int main() {
    int n;
    scanf("%d", &n);
    Friend fri[10];
    for (int i = 0; i < n; i++)
	 {
        scanf("%s %d %d %d", fri[i].name,&fri[i].year,&fri[i].month,&fri[i].day);
     }
    Friend youngest = fri[0];
    for (int i = 1; i < n; i++) 
	{
        if (fri[i].year > youngest.year || (fri[i].year == youngest.year && fri[i].month > youngest.month) ||
           (fri[i].year == youngest.year && fri[i].month == youngest.month && fri[i].day > youngest.day)) {
            youngest = fri[i];
        }
    }
    printf("%s %02d-%02d-%02d\n",  youngest.name, youngest.year, youngest.month, youngest.day);
    return 0;
}

